package com.circle.interests.biz.enums;

import lombok.Getter;

/**
 * @author zhou
 * @date 2021/1/15
 */
public enum PrizeStatusEnum {
    /**
     * 奖品状态
     */
    NOT_RECEIVE(1, "中奖未领取"),
    RECEIVED(2, "中奖已领取"),
    EXPIRED_OF_NOT_RECEIVE(3, "未领取已过期"),
    EXPIRED_OF_RECEIVED(4, "已领取已过期"),
    WRITE_OFF_ING(5, "核销中"),
    WRITE_OFF_SUCCESS(6, "已核销"),
    WRITE_OFF_FAIL(7, "核销失败");

    @Getter
    private final Integer code;
    @Getter
    private final String info;

    PrizeStatusEnum(Integer code, String info) {
        this.code = code;
        this.info = info;
    }

    public static PrizeStatusEnum getByCode(Integer code) {
        return getByCode(code, null);
    }

    public static PrizeStatusEnum getByCode(Integer code, PrizeStatusEnum defaultValue) {
        for (PrizeStatusEnum e : PrizeStatusEnum.values()) {
            if (e.code.equals(code)) {
                return e;
            }
        }
        return defaultValue;
    }
}
